home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbpxen / itemedit.frm < prev    next >
Text File  |  1995-10-23  |  10KB  |  414 lines

  1. VERSION 2.00
  2. Begin Form itemedit 
  3.    Caption         =   "Tape Inventory"
  4.    ClientHeight    =   5130
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   7695
  8.    Height          =   5535
  9.    Left            =   1035
  10.    LinkMode        =   1  'Source
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5130
  13.    ScaleWidth      =   7695
  14.    Top             =   1140
  15.    Width           =   7815
  16.    Begin CommandButton ButtonDone 
  17.       Caption         =   "E&xIt"
  18.       FontBold        =   -1  'True
  19.       FontItalic      =   0   'False
  20.       FontName        =   "MS Sans Serif"
  21.       FontSize        =   12
  22.       FontStrikethru  =   0   'False
  23.       FontUnderline   =   0   'False
  24.       Height          =   615
  25.       Left            =   6120
  26.       TabIndex        =   11
  27.       Top             =   4200
  28.       Width           =   975
  29.    End
  30.    Begin CommandButton ButtonDelete 
  31.       Caption         =   "&Delete"
  32.       Height          =   615
  33.       Left            =   4440
  34.       TabIndex        =   14
  35.       Top             =   4200
  36.       Visible         =   0   'False
  37.       Width           =   1095
  38.    End
  39.    Begin CommandButton ButtonCancel 
  40.       Caption         =   "&Cancel"
  41.       Height          =   615
  42.       Left            =   1920
  43.       TabIndex        =   13
  44.       Top             =   4200
  45.       Visible         =   0   'False
  46.       Width           =   1095
  47.    End
  48.    Begin CommandButton ButtonOK 
  49.       Caption         =   "&OK"
  50.       Height          =   615
  51.       Left            =   360
  52.       TabIndex        =   12
  53.       Top             =   4200
  54.       Visible         =   0   'False
  55.       Width           =   975
  56.    End
  57.    Begin CommandButton ButtonNew 
  58.       Caption         =   "&Add"
  59.       Height          =   495
  60.       Left            =   6120
  61.       TabIndex        =   10
  62.       Top             =   3240
  63.       Width           =   975
  64.    End
  65.    Begin CommandButton ButtonEdit 
  66.       Caption         =   "&Edit"
  67.       Height          =   495
  68.       Left            =   6120
  69.       TabIndex        =   9
  70.       Top             =   2280
  71.       Width           =   975
  72.    End
  73.    Begin CommandButton ButtonLast 
  74.       Caption         =   "&Last"
  75.       Height          =   375
  76.       Left            =   6720
  77.       TabIndex        =   8
  78.       Top             =   1560
  79.       Width           =   735
  80.    End
  81.    Begin CommandButton ButtonFirst 
  82.       Caption         =   "&First"
  83.       Height          =   375
  84.       Left            =   5880
  85.       TabIndex        =   7
  86.       Top             =   1560
  87.       Width           =   735
  88.    End
  89.    Begin CommandButton ButtonNext 
  90.       Caption         =   "&Next"
  91.       Height          =   375
  92.       Left            =   6720
  93.       TabIndex        =   6
  94.       Top             =   960
  95.       Width           =   735
  96.    End
  97.    Begin CommandButton ButtonPrior 
  98.       Caption         =   "&Prior"
  99.       Height          =   375
  100.       Left            =   5880
  101.       TabIndex        =   5
  102.       Top             =   960
  103.       Width           =   735
  104.    End
  105.    Begin TextBox tapetitle 
  106.       Height          =   375
  107.       Left            =   2160
  108.       TabIndex        =   2
  109.       Text            =   " "
  110.       Top             =   960
  111.       Width           =   3495
  112.    End
  113.    Begin TextBox tapenumber 
  114.       Height          =   375
  115.       Left            =   2160
  116.       TabIndex        =   1
  117.       Text            =   " "
  118.       Top             =   480
  119.       Width           =   1215
  120.    End
  121.    Begin CommandButton ButtonFind 
  122.       Caption         =   "&Get"
  123.       Height          =   495
  124.       Left            =   6120
  125.       TabIndex        =   3
  126.       Top             =   240
  127.       Width           =   975
  128.    End
  129.    Begin Label Label4 
  130.       Caption         =   "In/Out:"
  131.       Height          =   375
  132.       Left            =   3720
  133.       TabIndex        =   17
  134.       Top             =   1800
  135.       Width           =   735
  136.    End
  137.    Begin Label inout_code 
  138.       BorderStyle     =   1  'Fixed Single
  139.       Caption         =   " "
  140.       Height          =   375
  141.       Left            =   4560
  142.       TabIndex        =   18
  143.       Top             =   1680
  144.       Width           =   735
  145.    End
  146.    Begin Label custnum 
  147.       BorderStyle     =   1  'Fixed Single
  148.       Caption         =   " "
  149.       Height          =   375
  150.       Left            =   2160
  151.       TabIndex        =   16
  152.       Top             =   1680
  153.       Width           =   1215
  154.    End
  155.    Begin Label Label3 
  156.       Caption         =   "Custmomer checkout:"
  157.       Height          =   495
  158.       Left            =   600
  159.       TabIndex        =   15
  160.       Top             =   1680
  161.       Width           =   1215
  162.    End
  163.    Begin Label Label2 
  164.       Caption         =   "Title"
  165.       Height          =   255
  166.       Left            =   600
  167.       TabIndex        =   0
  168.       Top             =   1080
  169.       Width           =   1335
  170.    End
  171.    Begin Label Label1 
  172.       Caption         =   "Tape number:"
  173.       Height          =   255
  174.       Left            =   600
  175.       TabIndex        =   4
  176.       Top             =   600
  177.       Width           =   1455
  178.    End
  179. End
  180. Dim iMode As Integer
  181. Dim blankitemrec As ITEM
  182. Dim saveitemrec As ITEM
  183.  
  184. Const EDIT_MODE = 0
  185. Const ADD_MODE = 1
  186. Const VIEW_MODE = 2
  187.  
  188.  
  189. Sub ButtonCancel_Click ()
  190.     If iMode = ADD_MODE Then
  191.         itemrec = saveitemrec
  192.         rc = GetItemRec(DBKEYED)
  193.         If rc Then
  194.             rc = GetItemRec(DBFIRST)
  195.         End If
  196.     End If
  197.  
  198.     FieldsToForm
  199.     SetEditMode VIEW_MODE
  200. End Sub
  201.  
  202. Sub ButtonDelete_Click ()
  203.     '
  204.     '  check if user pressed OK or CANCEL
  205.     '
  206.     Msg$ = "OK to delete?"
  207.     
  208.     rc = MsgBox(Msg$, MB_OKCANCEL + MB_ICONQUESTION, "DELETE")
  209.     If rc = IDCANCEL Then
  210.         SetEditMode VIEW_MODE
  211.         Exit Sub
  212.     End If
  213.  
  214.     rc = DeleteItemRec()
  215.  
  216.     If rc Then
  217.         MsgBox "Delete failed, code: " + Str$(rc)
  218.         Beep
  219.     End If
  220.  
  221.     rc = GetItemRec(DBNEXT)
  222.     If rc Then
  223.         rc = GetItemRec(DBLAST)
  224.     End If
  225.     
  226.     FieldsToForm
  227.     SetEditMode VIEW_MODE
  228.  
  229. End Sub
  230.  
  231. Sub ButtonDone_Click ()
  232.     Unload itemedit
  233. End Sub
  234.  
  235. Sub ButtonEdit_Click ()
  236.     screen.MousePointer = POINTER_HOURGLASS
  237.     rc = GetItemRecForUpdate()
  238.     If rc Then
  239.         screen.MousePointer = POINTER_DEFAULT
  240.         Exit Sub
  241.     End If
  242.     '
  243.     '  Move the fields to the form again
  244.     '  In a network environment, someone could have
  245.     '  changed the record since last time is was shown
  246.     '
  247.     FieldsToForm
  248.     SetEditMode EDIT_MODE
  249.     screen.MousePointer = POINTER_DEFAULT
  250. End Sub
  251.  
  252. Sub ButtonFind_Click ()
  253.     FormToFields
  254.     
  255.     rc = GetItemRec(DBKEYED)
  256.     If rc Then
  257.         Exit Sub
  258.     End If
  259.     
  260.     FieldsToForm
  261.  
  262. End Sub
  263.  
  264. Sub ButtonFirst_Click ()
  265.     rc = GetItemRec(DBFIRST)
  266.     If rc = DB_OK Then
  267.         FieldsToForm
  268.     End If
  269. End Sub
  270.  
  271. Sub ButtonLast_Click ()
  272.     rc = GetItemRec(DBLAST)
  273.     If rc = DB_OK Then
  274.         FieldsToForm
  275.     End If
  276. End Sub
  277.  
  278. Sub ButtonNew_Click ()
  279.     Dim numvalue As Long
  280.  
  281.     SetEditMode ADD_MODE
  282.     saveitemrec = itemrec
  283.  
  284.     rc = GetItemRec(DBLAST)
  285.     If rc Then
  286.         numvalue = 1
  287.     Else
  288.         numvalue = Val(itemrec.itemnumber)
  289.     End If
  290.  
  291.     numvalue = numvalue + 1
  292.  
  293.     itemrec = blankitemrec
  294.     itemrec.itemnumber = LTrim$(Str$(numvalue))
  295.     FieldsToForm
  296.  
  297. End Sub
  298.  
  299. Sub ButtonNext_Click ()
  300.     rc = GetItemRec(DBNEXT)
  301.     If rc = DB_OK Then
  302.         FieldsToForm
  303.     End If
  304. End Sub
  305.  
  306. Sub ButtonOK_Click ()
  307.    FormToFields
  308.  
  309.     If iMode = ADD_MODE Then
  310.         rc = AddItemRec()
  311.     End If
  312.  
  313.     If iMode = EDIT_MODE Then
  314.         rc = UpdateItemRec()
  315.     End If
  316.     '
  317.     '  Assume if one of these failed, a message was
  318.     '  already displayed as part of the function.
  319.     '
  320.     '  What to do if the add or update failed?
  321.     '  For now invoke the CANCEL routine as though
  322.     '  the user clicked the cancel button.
  323.     '
  324.     If rc Then
  325.         ButtonCancel_Click
  326.         Exit Sub
  327.     End If
  328.     '
  329.     '  Return to vie